<template>
    <div>
        <el-drawer title="bug处理记录" size="60%" :visible.sync="drawer" :direction="direction">
            <el-row style="width: 100%;">
                <el-col :span="17" :xs="18">
                    <template v-if="content">
                        <span style="font-size: 20px;font-weight: bolder;">描述：
                            <editor v-model="content.descriptions" :showTool="false" :readOnly="true" :height="250" />
                        </span>
                        <span style="font-size: 20px;font-weight: bolder;">分析对策：
                            <editor v-model="content.analysisAnswer" :showTool="false" :readOnly="true" :height="250" />
                        </span>
                    </template>
                    <template v-else>
                        <el-empty :image-size="200"></el-empty>
                    </template>
                </el-col>

                <el-col :span="6" style="margin-top: 30px;overflow-x: hidden;
                overflow-y: auto;height: 800px;">
                    <div style="text-align: center;width: 100%;">历史记录</div>
                    <div class="block">
                        <el-timeline>
                            <template v-for="(item, index) in handleLogs">
                                <el-timeline-item :timestamp="`${parseTime(item.createTime, '{y}-{m}-{d} {h}:{i}:{s}')}`"
                                    placement="top">
                                    <el-card>
                                        <template v-if="index == 0">
                                            <h4>创建人：{{ item.handleUserName }}</h4>
                                        </template>
                                        <template v-else>
                                            <h4>处理人：{{ item.handleUserName }}</h4>
                                        </template>
                                        <p>版本：{{ item.version }}</p>
                                        <p>状态：
                                            <template v-if="item.handleStatus == '0'">
                                                待确认
                                            </template>
                                            <template v-else>
                                                {{ item.bugStatusTxt }}
                                            </template>
                                        </p>
                                    </el-card>
                                </el-timeline-item>
                            </template>
                        </el-timeline>
                    </div>
                </el-col>
            </el-row>
        </el-drawer>
    </div>
</template>

<script>
import { getBugHandleLog } from "@/api/business/bugs";
import { BugHnadleHistory } from "@/api/business/descriptions"
export default {
    name: 'BugHandleHistory',
    // props: {
    //     content: {
    //         type: Object,
    //         default: undefined
    //     }
    // },
    data() {
        return {
            content:undefined,
            bid: undefined,
            direction: 'rtl',
            drawer: false,
            handleLogs:[]
        };
    },
    computed: {
    },
    watch: {
    },
    created() {

    },
    methods: {
        open(value) {
            if(value){
                this.bid = value
                this.getBugHandleLogList()
                this.getDescriptionsAnalysis()
            }
            this.drawer = true
        },
        //获取bug处理日志
        getBugHandleLogList() {
            if (this.bid) {
                getBugHandleLog(this.bid).then(result => {
                    // console.log(result);
                    this.handleLogs = result.data
                })
            }

        },
        //获取bug处理详情
        getDescriptionsAnalysis() {
            if (this.bid) {
                BugHnadleHistory(this.bid).then(res => {
                    // console.log(res)
                    this.content = res.data
                })
            }

        },
    },
};
</script>

<style scoped></style>
